/**
 * Created by Administrator on 2015/6/15.
 */

var Fiber = require('fibers');

exports.viewInit = function(app){
    app.use(function (req, res, next) {
        var logger = require('./logger');
        var fiber = Fiber(function () {
            logger.info("start  process[ " + req.method + " ]request : " + req.originalUrl);
            var start = new Date().getMilliseconds();
            next();
            var end = new Date().getMilliseconds();
            logger.info("finish  process[ " + req.method + " ]request : " + req.originalUrl + ",cost : " + (end - start) + "ms");
        });
        logger.info("before fiber run~");
        fiber.run();
        logger.info("after fiber run~");
    });
    app.use('/api/managers', require('./controllers/managerController'));
    app.use('/', require('./controllers/indexController'));
}